//
//  FileMsgCell.m
//  ChangChat
//
//  Created by Cocoa on 2019/8/22.
//  Copyright © 2019 yibai. All rights reserved.
//

#import "FileMsgCell.h"

@implementation FileMsgCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    
    self.fileImgView = [UIImageView new];
    self.fileImgView.image = UIImage.k_imgName(@"msg_placeholder_file");
    self.fileNameLabel = [UILabel k_labelWithFontSize:15 textColor:UIColor.k_t2Color];
    self.fileNameLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
    self.fileNameLabel.numberOfLines = 2;
    self.fileSizeLabel = [UILabel k_labelWithFontSize:12 textColor:UIColor.k_t3Color];
    
    [self.msgContentView addSubview:self.fileImgView];
    [self.msgContentView addSubview:self.fileNameLabel];
    [self.msgContentView addSubview:self.fileSizeLabel];
//    self.msgContentView.backgroundColor = UIColor.whiteColor;
    self.msgContentView.backgroundColor = UIColor.k_hexColor(0xf7f7f7);

    
    [self.fileImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_offset(Chat_MsgContent_Padding);
        make.size.mas_equalTo(CGSizeMake(40, 43));
        make.bottom.mas_offset(-Chat_MsgContent_Padding).priorityLow();
    }];
    [self.fileNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.fileImgView.mas_right).offset(5);
        make.right.mas_offset(-Chat_MsgContent_Padding);
        make.top.equalTo(self.fileImgView);
    }];
    
    [self.fileSizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.fileNameLabel);
        make.top.equalTo(self.fileNameLabel.mas_bottom).offset(5);
        make.bottom.lessThanOrEqualTo(self.msgContentView).offset(-Chat_MsgContent_Padding);
    }];
    
    [self.msgContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(Chat_MsgContent_MaxWidth);
    }];
    
    self.fileNameLabel.text = arc4random()%2 == 0 ? @"上岛咖啡.word" : @"跨境电商康复科撒娇阿sdfjkweiq藕节速度快放假萨德快递费SDK.word";
    self.fileSizeLabel.text = @"11k";
}

- (void)setMsgModel:(MsgModel *)msgModel {
    [super setMsgModel:msgModel];
    
    self.fileNameLabel.text = msgModel.msg.file_name;
    self.fileSizeLabel.text = msgModel.msg.file_size;
}

@end
